﻿Public Class FormJPCheck
    'Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    'Dim txt As TextBox
    Public usr As String
    Public mes_project_name As String = String.Empty
    Dim objJlMst As New clsJlMst
    Dim objJpCheck As New clsJpCheck
    Dim update_status As String = "INSERT_TYPE"
    Dim en As entityJPCheck
    Dim _sys_id As String

    Public Property Sys_id As String
        Get
            Return _sys_id
        End Get
        Set(value As String)
            _sys_id = value
        End Set
    End Property
    Private Sub FormJPCheck_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        initForm()
        If _sys_id <> "" Then
            update_status = "UPDATE_TYPE"
            setContentBySysid()
        Else
            update_status = "INSERT_TYPE"
        End If
    End Sub

    Private Sub initForm()
        Dim TDate As String = Date.Now.ToShortDateString()
        dateJp.Text = TDate
        dateCheck.Text = TDate
        Dim dtJl As DataTable = objJlMst.getList()
        cmb_jl_type.DisplayMember = "mst_value"
        cmb_jl_type.ValueMember = "mst_value"
        cmb_jl_type.DataSource = dtJl
        If dtJl.Rows.Count > 0 Then
            cmb_jl_type.SelectedIndex = 0
        End If
        txtJpType.Text = String.Empty
        txt_project_name.Text = String.Empty
        txt_t10.Value = 0
        txt_t90.Value = 0
        txt_ml.Value = 0
        txt_mh.Value = 0
        txt_yd.Value = 0
        txt_ls.Value = 0
        txt_dl.Value = 0
        txt_ds25.Value = 0
        txt_ds100.Value = 0
        txt_ds300.Value = 0
        txt_ds400.Value = 0
        txt_md.Value = 0
        rbOK_jp.Checked = True
        txt_note.Text = String.Empty
    End Sub

    Private Sub setContentBySysid()
        Dim dt As DataTable = objJpCheck.selectBySysid(_sys_id)
        If dt.Rows.Count > 0 Then
            Dim row As DataRow = dt.Rows(0)
            dateJp.Text = row("date_jp")
            dateCheck.Text = row("date_check")
            cmb_jl_type.Text = row("jl_type")
            txtJpType.Text = row("jp_type")
            txt_project_name.Text = row("project_name")
            txt_t10.Text = row("lh_t10")
            txt_t90.Text = row("lh_t90")
            txt_ml.Text = row("lh_ml")
            txt_mh.Text = row("lh_mh")
            txt_yd.Text = row("lx_yd")
            txt_ls.Text = row("lx_ls")
            txt_dl.Text = row("lx_dl")
            txt_ds25.Text = row("lx_ds25")
            txt_ds100.Text = row("lx_ds100")
            txt_ds300.Text = row("lx_ds300")
            txt_ds400.Text = row("lx_ds400")
            txt_md.Text = row("jp_md")
            If row("check_result") = 1 Then
                rbOK_jp.Checked = True
            End If
            If row("check_result") = 0 Then
                rbNG_jp.Checked = True
            End If
            txt_note.Text = row("note")
        End If
    End Sub

    Public Sub setTxtProjectName()
        txt_project_name.Text = mes_project_name
    End Sub

    'Private Sub txt_MouseDown(sender As Object, e As MouseEventArgs) Handles SpinEdit1.MouseDown, txt_primer_curing_agent_count.MouseDown,
    '    SpinEdit2.MouseDown, SpinEdit3.MouseDown, txt_medium_paint_curing_agent_count.MouseDown,
    '    SpinEdit4.MouseDown, SpinEdit5.MouseDown, SpinEdit6.MouseDown
    '    UcDigitalKeyboard1 = New ucDigitalKeyboard
    '    If sender.MaskBox.Mask.EditMask = "d" Then
    '        UcDigitalKeyboard1.B_01 = False
    '    Else
    '        UcDigitalKeyboard1.B_01 = True
    '    End If

    '    If sender.GetType().Name.Equals("TextEdit") Then
    '        UcDigitalKeyboard1.B_02 = True
    '    Else
    '        UcDigitalKeyboard1.B_02 = False
    '    End If

    '    UcDigitalKeyboard1.Txt = sender

    '    Me.Controls.Add(UcDigitalKeyboard1)
    '    UcDigitalKeyboard1.Show()
    '    UcDigitalKeyboard1.BringToFront()
    '    UcDigitalKeyboard1.Focus()
    'End Sub

    'Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs) Handles txtDate.MouseClick, TextBox1.MouseClick
    '    txt = CType(sender, TextBox)
    '    DateNavigator1.Left = txt.Left
    '    DateNavigator1.Top = txt.Location.Y + txt.Height
    '    DateNavigator1.Visible = True
    'End Sub

    'Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs) Handles DateNavigator1.DateTimeChanged
    '    txt.Text = DateNavigator1.DateTime.ToShortDateString()
    '    DateNavigator1.Visible = False
    'End Sub

    Private Sub setEntity()
        en = New entityJPCheck
        With en
            .sys_id = _sys_id
            .factory_id = "TS"
            .date_jp = dateJp.Text
            .date_check = dateCheck.Text
            .jl_type = cmb_jl_type.Text
            .jp_type = txtJpType.Text.Trim()
            .project_name = txt_project_name.Text.Trim()
            .lh_t10 = txt_t10.Text
            .lh_t90 = txt_t90.Text
            .lh_ml = txt_ml.Text
            .lh_mh = txt_mh.Text
            .lx_yd = txt_yd.Text
            .lx_ls = txt_ls.Text
            .lx_dl = txt_dl.Text
            .lx_ds25 = txt_ds25.Text
            .lx_ds100 = txt_ds100.Text
            .lx_ds300 = txt_ds300.Text
            .lx_ds400 = txt_ds400.Text
            .jp_md = txt_md.Text
            .check_result = IIf(rbOK_jp.Checked = True, "1", "0")
            .note = txt_note.Text
            .oper = usr
        End With
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If String.IsNullOrEmpty(dateJp.Text.Trim()) Then
            MsgBox("请选择出片日期", vbYes, "提示")
            Exit Sub
        End If

        If String.IsNullOrEmpty(dateCheck.Text.Trim()) Then
            MsgBox("请选择检测日期", vbYes, "提示")
            Exit Sub
        End If

        If String.IsNullOrEmpty(txtJpType.Text.Trim()) Then
            MsgBox("请输入胶片规格", vbYes, "提示")
            Exit Sub
        End If

        If String.IsNullOrEmpty(txt_project_name.Text.Trim()) Then
            MsgBox("请输入所用项目", vbYes, "提示")
            Exit Sub
        End If

        setEntity()
        If update_status = "INSERT_TYPE" Then
            If objJpCheck.insert(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                initForm()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
        If update_status = "UPDATE_TYPE" Then
            If objJpCheck.update(en) <> -2 Then
                MsgBox("保存成功", vbYes, "提示")
                CType(Owner, FormJPCheckRecord).setDgvData()
                Close()
            Else
                MsgBox("保存失败", vbYes, "提示")
            End If
        End If
    End Sub

    Private Sub btnTiQuFromMesPlan_Click(sender As Object, e As EventArgs) Handles btnTiQuFromMesPlan.Click
        Dim formMesPlan As New FormMesPlan()
        formMesPlan.usr = usr
        formMesPlan.btnShow = True
        formMesPlan.ShowDialog(Me)
    End Sub
End Class


Public Class entityJPCheck
    Public sys_id As String
    Public factory_id As String
    Public date_jp As String '出片日期
    Public date_check As String '检测日期
    Public jl_type As String '胶料型号
    Public jp_type As String '胶片规格
    Public project_name As String '所用项目
    Public lh_t10 As String 'T10/min
    Public lh_t90 As String 'T90/min
    Public lh_ml As String 'ML/dNm
    Public lh_mh As String 'MH/dNm
    Public lx_yd As String '硬度/邵氏A
    Public lx_ls As String '拉伸强度/MPa
    Public lx_dl As String '断裂伸长率/%
    Public lx_ds25 As String '25%定伸/MPa
    Public lx_ds100 As String '100%定伸/MPa
    Public lx_ds300 As String '300%定伸/MPa
    Public lx_ds400 As String '400%定伸/MPa
    Public jp_md As String '密度g/cm³
    Public check_result As String '检测结论
    Public note As String '工艺意见
    Public oper As String '操作人
End Class